package webModule
{
	import com.greensock.TweenMax;
	import com.touchX.display.AbstractDisplay;
	import com.touchX.display.MusicRects;
	
	import flash.display.DisplayObject;
	import flash.display.GradientType;
	import flash.display.SpreadMethod;
	import flash.events.Event;
	import flash.geom.Matrix;
	
	public class Header extends AbstractDisplay
	{
		[Embed(source="../assets/logo.png")]
		private var Logo:Class;
		private var zoomControler:ZoomControler;
		private var logo:DisplayObject;
		private var musicVisualizer:MusicRects;
		public function Header()
		{
			super();
			logo=new Logo as DisplayObject;
			zoomControler=new ZoomControler();
			musicVisualizer=new MusicRects();
			
			logo.x=30;
			logo.y=10;
			addChild(logo);
			
			addChild(musicVisualizer);
			musicVisualizer.y=8;
			
			zoomControler.y=30;
			addChild(zoomControler);
		}
		protected override function added(event:Event):void{
			super.added(event);
			TweenMax.from(this,.5,{y:-200});
		}
		protected override function resize(event:Event=null):void{
			super.resize(event);
			drawBg();
			
			zoomControler.x=stage.stageWidth-20;
			musicVisualizer.x=stage.stageWidth-30;
		}
		private function drawBg():void{
			this.graphics.clear();
			this.graphics.beginFill(0x000000);
			this.graphics.drawRect(0,0,stage.stageWidth,50);
			
			
			var fillType:String = GradientType.LINEAR;
			var colors:Array = [0x000000, 0xffffff];
			var alphas:Array = [100, 100];
			var ratios:Array = [0x00, 0xFF];
			var matr:Matrix = new Matrix();
			matr.createGradientBox(stage.stageWidth/2,1, 0, 0, 0);
			var spreadMethod:String = SpreadMethod.REFLECT;
			this.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);  
			this.graphics.drawRect(0,50,stage.stageWidth,1);
			
			this.graphics.endFill();
		}
	}
}


import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.StageDisplayState;
import flash.events.Event;
import flash.events.MouseEvent;
class ZoomControler extends Sprite{
	[Embed(source="../assets/zoomIcon.png")]
	private var ZoomIcon:Class;
	public function ZoomControler(){
		addChild(new ZoomIcon as DisplayObject);
		this.alpha=.5;
		this.buttonMode=true;
		this.addEventListener(MouseEvent.MOUSE_OVER,setAlpha);
		this.addEventListener(MouseEvent.MOUSE_OUT,setAlpha);
		this.addEventListener(MouseEvent.CLICK,switchState);
	}
	private function setAlpha(evt:MouseEvent):void{
		this.alpha=evt.type==MouseEvent.MOUSE_OUT?.5 :1;
	}
	private function switchState(evt:MouseEvent):void{
		if(stage){
			stage.displayState=stage.displayState==StageDisplayState.FULL_SCREEN?StageDisplayState.NORMAL: StageDisplayState.FULL_SCREEN;
		}
	}
}